<!doctype>

{% extends "base.html" %}

{% block title %} Edit Post {% endblock %}

{% block js %}
	<script src="//cdn.ckeditor.com/4.9.2/standard/ckeditor.js"></script>
{% endblock %}

{% block user %} {{ current_user.username }} {% endblock %}

{% block body %}
	<div class="row-12">
		<h2> Edit Post </h1>
		<form method="POST" action="{{ url_for('blog.edit_post', id=post.id) }}"> {{ form.hidden_tag() }}
			
			<div class="form-group">
				{{ form.title.label }}
				
				{% if form.title.errors %}
					{% for e in form.title.errors %}
						<p class="help-block"> {{ e }} </p>
					{% endfor %}
				{% endif %}
				
				{{ form.title(class_='form-control', value=post.title) }}
			</div>
			
			<div class="form-group">
				{{ form.text.label }}
				
				{% if form.text.errors %}
					{% for e in form.text.errors %}
						<p class="help-block"> {{ e }} </p>
					{% endfor %}
				{% endif %}
				
				{{ form.text(id="editor", class_='form-control', value=post.text) }}
				<script> CKEDITOR.replace('editor'); </script>

			</div>
			<input class="btn-primary" type="submit" value="Submit">
		</form>
	</div>
{% endblock %}